<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%-- ssx --%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath %>">
<title>服务点信息统计</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<%-- 引用layui.css --%>
<link rel="stylesheet" type="text/css" href="<%=basePath %>js/layui/css/layui.css" />
<link rel="stylesheet" type="text/css"href="<%=basePath %>css/common.css" />
</head>
<body>
	<div class="ibox">
		<div class="ibox-content bodycss">
			<!-- 表单搜索 开始 -->
		 	<section class="panel panel-padding ">
			<form class="layui-form layui-form-pane form-search"
				onsubmit="return false" method="get">
				
				<div class="layui-form-item layui-inline">
				    <label class="layui-form-label">服务点</label>
				    <div class="layui-input-inline">
				      <select id="quiz1"  name="quiz1" lay-filter="projectfilter1">
				      </select>
				    </div>
				    <div class="layui-input-inline">
				      <select id="quiz2" name="quiz2" lay-filter="projectfilter2">
				      </select>
				    </div>
				    <div class="layui-input-inline">
				      <select id="quiz3" name="quiz3">
				      </select>
				    </div>
				</div>
				
  
				    <div class="layui-form-item layui-inline">
						<label class="layui-form-label" style="top:15px">日期</label>
						<div class="layui-input-inline">
					              <input type="datetime" name="startTime" class="layui-input" id="startTime" placeholder="开始时间" >
					    </div>
					</div>
					
					<div class="layui-form-item layui-inline">
						<div class="layui-input-inline">
					            <input type="datetime" name="endTime"  id="endTime"  placeholder="结束时间" class="layui-input">
					    </div>
					</div>
				<div class="layui-form-item layui-inline">
					<button class="layui-btn layui-btn-primary" lay-submit lay-filter="seach">
						<i class="layui-icon"></i> 查询
					</button>
				</div>
				
			
			
			</form>
			</section>
			<!-- 表单搜索 结束 -->
			<section class="panel panel-padding ">
				<c:if test="${sessionScope.userpopedom.ddgl03xcel eq '1' }"> <!-- pagecontext request session application -->
					<div class="ibox-toolbar">
						<button id="exportExcel" data-modal="" data-title="导出Excel"
								class="layui-btn layui-btn-sm">
								<i class="layui-icon">&#xe667;</i> 导出Excel
						</button>					
					</div>
				</c:if>
			<table class="layui-table"
				lay-data="{
	                        id: 'menuTeble',
	                        width:'auto',
	                        url:'fdj/list.do',
	                        method:'post',
	                        page:true,
	                        even:true,
	                        skin:'row',
	                        limits:[10,20,30,40,50],
	                        limit:10}"
				lay-filter="popedomLay">
				<thead>
					<tr>
						<th lay-data="{checkbox:true,disabledKey:'check_status',disabledKeyValue:'1,2'}"></th>
						<th lay-data="{type:'numbers', width:50}">序号</th>
						<th lay-data="{field:'area_id', width:200,align:'center'}">ID</th>
						<th lay-data="{field:'area_name', width:120,align:'center'}">名称</th>
						<th lay-data="{field:'tims', width:200,align:'center',}">时间</th>
						<th lay-data="{field:'amounts1', width:200,align:'center'}">收入金额</th>
						<th lay-data="{field:'orders1', width:200,align:'center'}">订单数量</th>
						<th lay-data="{field:'goods', width:200,align:'center'}">商品数量</th>
						<th lay-data="{field:'amounts2', width:200,align:'center'}">订单金额</th>
						<th lay-data="{field:'orders2', width:200,align:'center'}">出库订单量</th>
					</tr>
				</thead>
			</table>
			</section>
		</div>
	</div>
	
	
	<script type="text/javascript" src="<%=basePath %>js/layui/layui.js"></script>
	<script type="text/javascript">
	layui.config({
	    base: "<%=basePath%>js/common/"
	}).use(["common", "element", "layer", "form", "table", "jquery","laydate"], function(){
			var elem = layui.element;
			var layer = layui.layer;
			var form = layui.form;
			var table = layui.table;
			var $ = layui.jquery;
			var laydate = layui.laydate;
			var nowTime =new Date().valueOf();
			layui.common.init();	
			
			/* 时间段 */
	var start = laydate.render({
       elem: '#startTime',
       /* type: 'datetime',  日期时间选择器，不加默认日期 */
       format:'yyyy-MM-dd',
       max: nowTime,
       btns: ['clear', 'confirm'],
       done: function(value, date){
           endMax = end.config.max;
           end.config.min = date; //最大时间为结束时间的开始值
           end.config.min.month = date.month -1;
       }
   });
   
   var end = laydate.render({
       elem: '#endTime',
      /*  type: 'datetime', */
       max:  4073558400000,
       format:'yyyy-MM-dd',
       min:nowTime,
       done: function(value, date){
           if($.trim(value) == ''){
               var curDate = new Date();
               date = {'date': curDate.getDate(), 'month': curDate.getMonth()+1, 'year': curDate.getFullYear()};
           }
           start.config.max = date;//最小时间为开始时间的最大值
           start.config.max.month = date.month -1;
       }
   })
			
   

		//给级联框赋值
		$.ajax({
			url:"fdtj/list.do",
			data:{
				area_parent_id:0
			},
			method:"post",
			success:function(resultData){
			//	console.log(resultData);
				if(resultData.code == 0){
					$("#quiz1").append(new Option("请选择", ""));
					$.each(resultData.data, function(index, item) {
						$.each(item, function(index1, item1) {
							if(index1 == "area_name"){
								$('#quiz1').append(new Option(item1));
							}
						});
					});
				}else{
					$("#quiz1").append(new Option("暂无数据", ""));
				}
				layui.form.render("select");
			}
		});
		//级联二级子项目
		//select 监听
		form.on('select(projectfilter1)',function(data){
			var value=data.value;  //select选中的值
			$.ajax({
				url:"queryClassificationByName.do",
				data:{
					"area_name":value
				},
				method:"post",
				success:function(result){
					$("#quiz2").empty();
					$("#quiz3").empty();
				//	console.log(result);
					if(result.code == 0){
						$("#quiz2").append(new Option("请选择", ""));
						$.each(result.data, function(index, item) {
							$.each(item, function(index1, item1) {
								if(index1 == "area_name"){
									$('#quiz2').append(new Option(item1));
								}
							});
						});
					}else{
						$("#quiz2").append(new Option("暂无数据", ""));
					}
					layui.form.render("select");
				}
			})
		});
		//级联三级子项目
		//select 监听
		form.on('select(projectfilter2)',function(data){
			var value=data.value;  //select选中的值
			$.ajax({
				url:"queryClassificationByName.do",
				data:{
					"area_name":value
				},
				method:"post",
				success:function(result){
				//	console.log(result);
					$("#quiz3").empty();
					if(result.code == 0){
						$("#quiz3").append(new Option("请选择", ""));
						$.each(result.data, function(index, item) {
							$.each(item, function(index1, item1) {
							//	console.log(index1);
								if(index1 == "area_name"){
									$('#quiz3').append(new Option(item1));
								}
							});
						});
					}else{
						$("#quiz3").append(new Option("暂无数据", ""));
					}
					layui.form.render("select");
				}
			})
		});
   
   
			/**
			 * 监听刷新表格
			 */
		form.on('submit(seach)', function(data){
			if(data.field.quiz2=="" || data.field.quiz3==""){
				if(data.field.quiz2==""){
					layer.msg('请选择二级节点', {icon: 6});
				}else{
					layer.msg('请选择三级节点', {icon: 6});
				}
			 }else{
				 table.reload('menuTeble', {
						where: data.field,
						page : {
							curr : 1
						}
					}); 
			 } 
			return false;
		});
			
			
		//导出Excel
		$("#exportExcel").on("click", function(){
        	layer.load(2, {time: 1000}); 
        	window.location.href = "fdj/export.do?area_id="+$("#area_id").val()+"&area_name="+$("#area_name").val()+
        	"&tims="+$("#tims").val()+"&amounts1="+$("#amounts1").val()+"&amounts1="+$("#amounts1").val()+
        	"&orders1="+$("#orders1").val()+"&goods="+$("#goods").val()+
        	"&amounts2="+$("#amounts2").val()+"&orders2="+$("#orders2").val();
        });
	});
</script>
</body>
</html>
